﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class GameSweet : MonoBehaviour {
    private int x;
    public int X {
        get { return x; }
        set {
            if (CanMove()) {
                x = value;
            }
        }
    }
    private int y;
    public int Y {
        get { return y; }
        set {
            if (CanMove()) {
                y = value;
            }
        }
    }
    [HideInInspector]
    public GameManager gm;
    //甜品种类只可以读取,不可以修改
    public GameManager.SweetType Type { get; set; }
    public MovedSweet MovedSweetComponent { get; private set; }
    public ColorSweet ColorSweetComponent { get; private set; }
    void Awake() {
        MovedSweetComponent = GetComponent<MovedSweet>();
        ColorSweetComponent = GetComponent<ColorSweet>();
    }
    public bool CanMove() {
        return MovedSweetComponent != null;
    }
    public bool CanColor() {
        return ColorSweetComponent != null;
    }
    public void Init(int _x, int _y, GameManager _gm, GameManager.SweetType _type) {
        x = _x;
        y = _y;
        gm = _gm;
        Type = _type;
    }
}
